<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport", content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
    <meta name="keywords" content="米菲纸尿裤,荷兰米菲纸尿裤,纸尿裤">
    <meta name="description" content="米菲纸尿裤,荷兰米菲纸尿裤,纸尿裤。">
    <title>米菲纸尿裤-荷兰米菲，36.8℃会呼吸的纸尿裤</title>
    <style>
        * {
            margin: 0;
        }
        img {
            width: 100%;
        }
        area {
            outline: none;
        }
    </style>
</head>
<body>
    <img id="background" src="./background.jpg"  usemap="#planetmap">

    <map name="planetmap" id="planetmap">
        <area id="area1" shape="rect" coords="" href ="https://mp.weixin.qq.com/s/cqdIoWH0OVKl2JDw0xASJg" />
        <area id="area2" shape="rect" coords="" href ="http://h.eqxiu.com/s/nUiHPp3Q" />
    </map>

    <script>
        var IMG_ORIGINAL_SIZE = {
            WIDTH: 2000,
            HEIGHT: 4500
        };

        var $ = function(id) {
            return document.getElementById(id);
        };

        var calculate = function(posi) {
            var img = $('background');
            var height = img.clientHeight;
            var width = img.clientWidth

            var leftTop = [width * posi.leftTop[0], height * posi.leftTop[1]];
            var rightBottom = [width * posi.rightBottom[0], height * posi.rightBottom[1]];

            return leftTop.concat(rightBottom).join(', ');
        };

        var bind = function() {
            var position1 = {
                leftTop: [0.337,0.393],
                rightBottom: [0.6565, 0.482],
            };

            var coords1 = calculate(position1);
            var area1 = $('area1');
            area1.setAttribute('coords', coords1);

            var position2 = {
                leftTop: [0.5735, 0.2144],
                rightBottom: [0.9355, 0.2462] 
            };

            var coords2 = calculate(position2);
            var area2 = $('area2');
            area2.setAttribute('coords', coords2)
        };

        window.onresize = function() {
            bind.timer && clearTimeout(bind.timer);
            bind.timer = setTimeout(bind, 100);
        };

        window.onload = function() {
            bind();
        }
    </script>
</body>
</html>